package be.kuleuven.mume.paginas;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import be.kuleuven.mume.R;
import be.kuleuven.mume.framework.AgendaItem;
import be.kuleuven.mume.framework.Mobilenvi;

public class UpdatesTabBar extends TabActivity{
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.vaktab);
	    
	    setTitle(R.string.updates);
	    
	    addTab(AgendaPagina.class, "Agenda");
	    addTab(UpdatesPagina.class, "Vakken");
	    
        int childCount = getTabHost().getTabWidget().getChildCount();
	    for(int i=0; i<childCount; i++)
	    	getTabHost().getTabWidget().getChildAt(i).getLayoutParams().height = Mobilenvi.tabHeight;
	}
	
	private void addTab(Class<? extends Activity> pagina, String title ) {
	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, pagina);
	    intent.putExtra(AgendaPagina.FILTER_ID, AgendaItem.TypeItem.Updates);
	    
	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec(title).setIndicator(title)
	                  .setContent(intent);
	    tabHost.addTab(spec);
	}
}
